#include "privateinfo.h"
#include "ui_privateinfo.h"
#include<QFileDialog>
privateinfo::privateinfo(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::privateinfo)
{
    ui->setupUi(this);
}

privateinfo::~privateinfo()
{
    delete ui;
}

void privateinfo::init(QString na, QString im, QString personalsig,bool edit)
{
    name=na;
    image=im;
    personalsign=personalsig;
    ui->name->setText(name);
    ui->image->setIcon(QPixmap(image));
    ui->sign->setText(personalsign);
    if(!edit)
    {
        ui->save->hide();
        ui->name->setEnabled(false);
        ui->image->setEnabled(false);
        ui->sign->setEnabled(false);
    }
}

void privateinfo::on_image_clicked()
{
    QString newimage=QFileDialog::getOpenFileName(this,"",QDir::currentPath());
    image=newimage;
    ui->image->setIcon(QPixmap(image));
}


void privateinfo::on_save_clicked()
{
    name=ui->name->text();
    personalsign=ui->sign->text();
    emit renewprivateinfo(ui->name->text(),image,ui->sign->text());
    close();
}

